<?php
/**
 * 审批带奖励的群发邮件和单人奖励，审核通过后，真正发送给玩家
 */

require_once('../inc/config.php');
require_once ROOT_PATH .'/utility/class/socket.class.php';
//权限判断
chkpurview('approve_email');

$act = isset($_GET['action']) ? $_GET['action'] : null;

//审核通过发送
if($act == 'send')
{
	$sendData = array(
							array('type'=>1,'data'=>$min_level),
							array('type'=>1,'data'=>$max_level),
							array('type'=>1,'data'=>$profession),
							array('type'=>3,'data'=>$title),
							array('type'=>3,'data'=>$content),
							array('type'=>4,'data'=>$rewards),
							array('type'=>2,'data'=>$timing),
					);
					
	$protocol = 'email';
		
	$gamesocket = new gamesocket();
	$receive = $gamesocket->send($sendData, $protocol);
	if($receive['retcode'] == '00000000')
	{
		save_adminoper($oper_type, $oper_value, 1);				//0：发送成功 1：待审核；2：审核通过
		gourl($_LANG['operate_success'], 'email.php');
	}
	else 
	{
		save_adminoper($oper_type, $oper_value, $receive['retcode']);
		gourl($_LANG['operate_fail'], 'email.php');
	}
}

//未审核列表
$sql = "SELECT * FROM tb_ad_adminoper_hist WHERE `status` = 1";
$emails = array();
$rs = $db_master->query($sql);
while($row = $db_master->fetch_array($rs))
{
	$emails[] = $row;
}

$T->assign('emails',$emails);
$T->display('approve_email.html');


